import axios from 'axios'
const newAxios = axios.create({
  baseURL: 'http://127.0.0.1:5000/api/',
  timeout: 5000
})
newAxios.interceptors.request.use(config => {
  const token = window.sessionStorage.getItem('token')
  // if (token) {
  config.headers.Authorization = 'Bearer ' + token
  return config
  // }
})

getCookie(cname) {
  let name = cname + '='
  let ca = document.cookie.split(';');
  for (let i = 0; i < ca.length; i++) {
    let c = ca[i].trim()
    if (c.indexOf(name) == 0) return c.substring(name.length, c.length)
  }
  return ""
}
export default newAxios
